# Copyright (c) 2006 Nuxeo SARL <http://nuxeo.com>
# Author: Laurent Godard <lgodard@indesko.com>, Infrae <info@infrae.com>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the Lesser GNU General Public License version
# 2.1 as published by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
# 02111-1307, USA.
#
# See ``COPYING`` for more information

FILTERS = {
    'writer': {
    'PDF': {'FilterName': 'writer_pdf_Export',
            'Extension': 'pdf',
            'isGraphical': False,
            'zipMe': False},
    'OOO': {'FilterName': 'StarOffice XML (Writer)',
            'Extension': 'sxw',
            'isGraphical': False,
            'zipMe': False},
    'ODOC': {'FilterName': 'writer8', #OpenDocument OOo 2
             'Extension': 'odt',
             'isGraphical': False,
            'zipMe': False},
    'MSXP': {'FilterName': 'MS Word 97',
             'Extension': 'doc',
            'isGraphical': False,
             'zipMe': False},      
    'MS95': {'FilterName': 'MS Word 95',
            'Extension': 'doc',
             'isGraphical': False,
             'zipMe': False},                            
    'MS60': {'FilterName': 'MS WinWord 6.0',
             'Extension': 'doc',
             'isGraphical': False,
             'zipMe': False},     
    'RTF': {'FilterName': 'Rich Text Format',
            'Extension': 'rtf',
            'isGraphical': False,
            'zipMe': False},
    'HTML': {'FilterName': 'HTML (StarWriter)',
             'Extension': 'html',
             'isGraphical': False,
             'zipMe': True},  
    'XHTML': {'FilterName': 'XHTML plus MathML File',
              'Extension': 'xhtml',
              'isGraphical': False,
              'zipMe': True},                                         
    'TEX': {'FilterName': 'Latex File',
            'Extension': 'tex',
            'isGraphical': False,
            'zipMe': True},   
    'TXT': {'FilterName': 'Text',
            'Extension': 'txt',
            'isGraphical': False,
            'zipMe': False},         
    },
    'calc': {
    'PDF': {'FilterName': 'calc_pdf_Export',
            'Extension': 'pdf',
            'isGraphical': False,
            'zipMe': False},            
    'OOO': {'FilterName': 'StarOffice XML (Calc)',
            'Extension': 'sxc',
            'isGraphical': False,
            'zipMe': False},
    'ODOC': {'FilterName': 'calc8', #OpenDocument OOo 2
             'Extension': 'odc',
             'isGraphical': False,
             'zipMe': False},      
    'MSXP': {'FilterName': 'MS Excel 97',
             'Extension': 'xls',
             'isGraphical': False,
             'zipMe': False},      
    'MS95': {'FilterName': 'MS Excel 95',
             'Extension': 'xls',
             'isGraphical': False,
             'zipMe': False},                            
    'MS60': {'FilterName': 'MS Excel 5.0/95',
             'Extension': 'xls',
             'isGraphical': False,
             'zipMe': False},     
    'HTML': {'FilterName': 'HTML (StarCalc)',
             'Extension': 'html',
             'isGraphical': False,
             'zipMe': True},  
    'TXT': {'FilterName': 'Text',
            'Extension': 'txt',
            'isGraphical': False,
            'zipMe': False},
    },
    'draw': {
    'PDF': {'FilterName': 'draw_pdf_Export',
            'Extension': 'pdf',
            'isGraphical': False,
            'zipMe': False},  
    'OOO': {'FilterName': 'StarOffice XML (Draw)',
            'Extension': 'sxd',
            'isGraphical': False,
            'zipMe': False},
    'ODOC': {'FilterName': 'draw8', #OpenDocument OOo 2
             'Extension': 'odd',
             'isGraphical': False,
             'zipMe': False},  
    'JPG': {'FilterName': 'image/jpeg', 
            'Extension': 'jpg',
            'isGraphical': True,
            'zipMe': True},           
    'PNG': {'FilterName': 'image/png', 
            'Extension': 'png',
            'isGraphical': True,
            'zipMe': True},    
    'TIFF': {'FilterName': 'image/tiff', 
             'Extension': 'tif',
             'isGraphical': True,
             'zipMe': True},                                                                            
    'SVG': {'FilterName': 'image/svg+xml', 
            'Extension': 'svg',
            'isGraphical': True,
            'zipMe': True},  
    'EPS': {'FilterName': 'application/postscript',
            'Extension': 'eps',
            'isGraphical': True,
            'zipMe': True},    
    'SWF': {'FilterName': 'draw_flash_Export',
            'Extension': 'swf',
            'isGraphical': False,
            'zipMe': False},    
    'HTML': {'FilterName': 'draw_html_Export',
             'Extension': 'html',
             'isGraphical': False,
             'zipMe': True},                                               
    },
    'impress': {
    'PDF': {'FilterName': 'impress_pdf_Export',
            'Extension': 'pdf',
            'isGraphical': False,
            'zipMe': False},  
    'OOO': {'FilterName': 'StarOffice XML (Impress)',
            'Extension': 'sxi',
            'isGraphical': False,
            'zipMe': False},
    'ODOC': {'FilterName': 'impress8', #OpenDocument OOo 2
             'Extension': 'odp',
             'isGraphical': False,
             'zipMe': False},  
    'MSXP': {'FilterName': 'MS Powerpoint 97',
             'Extension': 'ppt',
             'isGraphical': False,
             'zipMe': False},    
    'JPG': {'FilterName': 'image/jpeg', 
            'Extension': 'jpg',
            'isGraphical': True,
            'zipMe': True},           
    'PNG': {'FilterName': 'image/png', 
            'Extension': 'png',
            'isGraphical': True,
            'zipMe': True},    
    'TIFF': {'FilterName': 'image/tiff', 
             'Extension': 'tif',
             'isGraphical': True,
             'zipMe': True},
    'SVG': {'FilterName': 'image/svg+xml', 
            'Extension': 'svg',
            'isGraphical': True,
            'zipMe': True},  
    'EPS': {'FilterName': 'application/postscript',
            'Extension': 'eps',
            'isGraphical': True,
            'zipMe': True},    
    'SWF': {'FilterName': 'impress_flash_Export',
            'Extension': 'swf',
            'isGraphical': False,
            'zipMe': False},    
    'HTML': {'FilterName': 'impress_html_Export',
             'Extension': 'html',
             'isGraphical': False,
             'zipMe': True},                               
    },
    }

def getFilter(docType, targetFormat):
    """Get a filter or return None if no filter could be found.
    """
    try:
        return FILTERS[docType][targetFormat]
    except KeyError:
        return None
    
